package org.graduation.feignapi;

import org.graduation.model.common.ResponseResult;
import org.graduation.model.common.note.Note;
import org.graduation.model.dtos.RBAC.AssignAndRevokeRoleDTO;
import org.graduation.model.dtos.RBAC.CheckPermissionsDTO;
import org.graduation.model.dtos.RBAC.UserAndNotePermissionsCheckerDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@FeignClient("RBAC-service")
public interface RBACClient {
    /**
     * 检查某个用户是否有相应权限，判断RequestResult.code属性是否为200，-1就是没权限。
     *
     * @param dto
     * @return
     */
    @RequestMapping(value = "/permission/check", method = RequestMethod.POST)
    ResponseResult check(@RequestBody CheckPermissionsDTO dto);

    @RequestMapping(value = "/permission/assign_role", method = RequestMethod.POST)
    ResponseResult assignRole(@RequestBody AssignAndRevokeRoleDTO dto);

    @RequestMapping(value = "/permission/revoke_role", method = RequestMethod.POST)
    ResponseResult revokeRoles(@RequestBody AssignAndRevokeRoleDTO dto);

    // note permissions
    @RequestMapping(value = "/rbac/note/assign_role", method = RequestMethod.POST)
    ResponseResult assignNoteRole(@RequestBody Note note);

    @RequestMapping(value = "/rbac/note/revoke_role", method = RequestMethod.POST)
    ResponseResult revokeNoteRoles(@RequestBody Note note);

    @RequestMapping(value = "/rbac/note/check", method = RequestMethod.POST)
    ResponseResult checkNotePermission(@RequestBody UserAndNotePermissionsCheckerDTO dto);
}
